package io.lkt.modules.sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.lkt.common.utils.PageUtils;
import io.lkt.common.utils.Query;
import io.lkt.commons.dynamic.datasource.annotation.DataSource;
import io.lkt.modules.sys.dao.PushHeadLogDao;
import io.lkt.modules.sys.dao.PythonArticleInfoDao;
import io.lkt.modules.sys.entity.PushDetailLogEntity;
import io.lkt.modules.sys.entity.PushHeadLogEntity;
import io.lkt.modules.sys.entity.PythonArticleInfoEntity;
import io.lkt.modules.sys.service.PushHeadLogService;
import io.lkt.modules.sys.service.PythonArticleInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


@Service("PushHeadLogService")
public class PushHeadLogServiceImpl extends ServiceImpl<PushHeadLogDao, PushHeadLogEntity> implements PushHeadLogService {
    @Autowired
    PushHeadLogDao pushHeadLogDao;

    @Override
    @DataSource("logdb")
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<PushHeadLogEntity> page = this.page(
                new Query<PushHeadLogEntity>().getPage(params),
                new QueryWrapper<PushHeadLogEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    @DataSource("logdb")
    public List<PushHeadLogEntity> queryList(Map<String, Object> map) {
        return pushHeadLogDao.queryList(map);
    }

    @Override
    @DataSource("logdb")
    public List<PushHeadLogEntity> queryVital(Map<String, Object> map) {
        return pushHeadLogDao.queryVital(map);
    }


    @Override
    @DataSource("logdb")
    public Integer queryTotal(Map<String, Object> map) {
        return pushHeadLogDao.queryTotal(map);
    }

    @Override
    @DataSource("logdb")
    public PushHeadLogEntity queryById(Integer id) {
        return pushHeadLogDao.queryById(id);
    }

    @Override
    public PageUtils getDetailById(Map<String, Object> params) {
        io.lkt.common.util.Query query = new io.lkt.common.util.Query(params);
        List<PushDetailLogEntity> list = pushHeadLogDao.getDetailById(params);
        int total = pushHeadLogDao.getDetailTotal(params);
        PageUtils page = new PageUtils(list, total, query.getLimit(), query.getPage());
        return page;
    }
}
